﻿using Company.Core.Helper;
using Company.Hardware.Ice_ipc;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using 无人值守地磅称重系统.ViewModels;

namespace 无人值守地磅称重系统.Views
{
    /// <summary>
    /// TestView.xaml 的交互逻辑
    /// </summary>
    public partial class TestView : UserControl
    {
        public TestView()
        {
            InitializeComponent();
            DataContext = App.Current.Services.GetService<TestViewModel>();
            Loaded += async (s, e) =>
            {
                var vm = DataContext as TestViewModel;
                if (!vm.HardwareManager.Initialized)
                {
                    ipcsdk.ICE_IPCSDK_Init(); //调用全局初始化
                    var result = vm.HardwareManager.InitializeAsync(pictureBox.Handle);
                    Log.Info($"硬件初始化结果：{result}");
                }
            };
        }

        
    }
}
